package com.springinaction.ch03.PlaceholderSpel;

import com.springinaction.ch02.CompactDisc;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
public class BlankDisc implements CompactDisc {
    private String title;
    private String artist;

//    public BlankDisc(
//            @Value("${a.title}") String title,
//            @Value("${a.artist}") String artist
//    ){
//        System.err.println(System.getProperties().toString());
//        this.title=title;
//        this.artist=artist;
//    }


    public BlankDisc(
      @Value("#{propertiesFactoryBean['a.title']}") String title,
      @Value("#{propertiesFactoryBean['a.artist']}") String artist
    ) {

        this.artist=artist;
        this.title=title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }


    @Override
    public void play() {
        System.out.println("Playing " + title + " by " + artist);

    }
    @Override
    public void destroy() {

    }
}
